package io.bitmax.library.mvp;

import android.content.res.Resources;
import android.os.Bundle;

import java.lang.ref.WeakReference;

/**
 * Created by gongdongyang on 2018/9/17.
 */

public abstract class BasePresenter<V extends IBaseUI>  {

    private BaseCoreActivity activity;

    private WeakReference<V> mUI;

    public void onStart() {

    }

    public void onResume() {

    }

    public void onPause() {

    }

    public void onStop() {

    }

    public void onDestroy() {
    }

    public void onRestoreInstanceState(Bundle savedInstanceState) {

    }

    public void onSaveInstanceState(Bundle outState) {

    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {

    }

    public BaseCoreActivity getActivity() {
        return activity;
    }

    public V getmUI() {
        return mUI == null ? null : mUI.get();
    }

    public Resources getResources() {
        return activity.getResources();
    }

    public String getString(int resId) {
        return getResources().getString(resId);
    }

    public void onUIReady(BaseCoreActivity activity,V ui){
        this.activity = activity;
        this.mUI = new WeakReference<V>(ui);
    }

}
